package org.example.mock.customer.impl;

import org.example.customer.api.SdkCustomerDTO;
import org.example.customer.api.CustomerService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class CustomerServiceImpl implements CustomerService {
    @Override
    public SdkCustomerDTO getCustomer(String customerId) {
        return createCustomerDTO(customerId, 1);
    }

    @Override
    public List<SdkCustomerDTO> getCustomers(List<String> customerIds) {
        List<SdkCustomerDTO> result = new ArrayList<>();
        for (int i = 0; i < customerIds.size(); i++) {
            result.add(createCustomerDTO(customerIds.get(i), i + 1));
        }
        return result;
    }

    private SdkCustomerDTO createCustomerDTO(String orgId, int index) {
        SdkCustomerDTO sdkCustomerDTO = new SdkCustomerDTO();
        sdkCustomerDTO.setId(orgId);
        sdkCustomerDTO.setCode("code" + index);
        sdkCustomerDTO.setName("name" + index);
        return sdkCustomerDTO;
    }
}
